$(function () {
    var shopSearchPage = function () {
        this.init();
    };
    shopSearchPage.prototype = {
        // 初始化
        init: function () {
            this.bindEvent();
        },

        // 绑定事件
        bindEvent: function () {
            var model = this;
            // 回退
            $("#btncloseseahpage").on("tap", function () {
                parent.closeSearchPage();
            });

            // 搜索
            $("#btnsearch").on("tap", function () {
                var searchword = $("#searchtext").val();

                model.search(searchword);
            });

            $("#searchtext").on("keydown", function (e) {
                e = e || event;
                if (e.keyCode == 13) {  //判断是否单击的enter按键(回车键)
                    var searchword = $("#searchtext").val();

                    model.search(searchword);
                }
            });
        },

        // 选择条件后回掉函数
        search: function (searchword) {
            $("#searchtext").val("");
            parent.search(searchword);
            parent.closeSearchPage();
        }
    };

    var _shopSearchPage = new shopSearchPage();
});
function show(searchtext) {
    $("#searchtext").val(searchtext).focus();
}